package edu.gatech.aristotle.random.experiment;

import java.util.ArrayList;

import net.util.File_Handler;

import edu.gatech.aristotle.random.util.CONSTANT_FILE_NAME;
import edu.gatech.aristotle.random.util.Util_FormatHandler;

public class SpaceRandomTestCaseAnalyzer implements CONSTANT_FILE_NAME {
	public int findKthVersionNthThousandTestCaseReport( int k, int n ){
		ArrayList<Integer> intResultList = this.getKthVersionTestResult(k);
	
		int failedTestCase	= this.failedTestCaseInNthThousand( n, intResultList );
		
		return failedTestCase;
	}
	
	public ArrayList<Integer> getKthVersionTestResult( int k ){
		String spaceResultFileName	= matrixNewFormatFileNames[ matrixNewFormatFileNames.length - 1 ];
		
		ArrayList<String> allVersionTestResultStrings = File_Handler.fileContentToStrings( spaceResultFileName );
		
		String kthVersionTestResultString	= allVersionTestResultStrings.get( k );
		
		return Util_FormatHandler.oneStringToInteger( kthVersionTestResultString );
	}
	

	
	public int failedTestCaseInNthThousand( int n, ArrayList<Integer> integerList ){
		int numberOfFailedTestCase;
		
		int startIndex	= ( n  - 1 ) * 1000 + 1;
		int endIndex	= n * 1000;
		
		ArrayList<Integer> NthThousandInteger	= new ArrayList<Integer>();
		for ( int i = startIndex; i < endIndex + 1; i++ ){
			NthThousandInteger.add( integerList.get(i) );
		}
		
		numberOfFailedTestCase = Util_FormatHandler.sumIntegerList( NthThousandInteger );
		
		
		return numberOfFailedTestCase;
	}
}
